<?php $this->load->view('header'); ?>
 <div id="title_background">
	<div class="wrapper"><!-- 900px wrapper -->
		<h1>Article</h1>
		<!--<span class="title_description">This is crossroads for features. Here you could describe your page or leave it blank.</span>-->
	</div> <!-- 900px wrapper -->
</div>
</div>
<div class="cleaner"></div>
<div id="position_navi"><a href="index.html">Beranda</a> / Photo</div>
<div id="content">
<article>
<h2>Artikel Anda</h2>
<a href="<?php echo base_url()."articles/add";?>"><button class="button" style="width: auto!important">Tulis Artikel Baru</button></a>
<table class="style1" id="user_articles">
	<thead>
		<tr class="first">
			<td>No</td>
			<td></td>
			<td>Judul</td>
			<td>Kategori</td>
			<td>Waktu Posting</td>
			<td>Status</td>
			<td></td>
		</tr>
	</thead>
	<tbody id="article-body">
	<?php 
	$no = 1;
	if(count($articles) > 0){
		foreach($articles as $article){ ?>
			<tr>
				<td><?php echo $no;?></td>
				<td><img src="<?php echo base_url()."images/article_images/" . $article['foto'] ;?>" width="100"></td>
				<td><?php echo $article['judul'];?></td>
				<td>
					<?php
					$i =0;
					foreach(unserialize(ARTICLE_CATEGORY) as $kategori){
						if($i == $article['kategori']){
							echo $kategori;
						}
						$i++;
					}?></td>
				<td><?php echo timestamp_to_date_time($article['waktu_posting']); ?></td>
				<td><?php echo $article['status']; ?></td>
				<td><a title="Edit" class="edit_icon" href="<?php echo base_url()."articles/edit/".$article['id_artikel'];?>">
					<a title="Delete" class="delete_icon" href="javascript:confirm_delete('<?php echo base_url()."articles/delete/".$article['id_artikel'];?>')"></td>
			</tr>
		<?php 
		$no++;
		} 
	}else{
		echo '<tr><td colspan="7">Belum ada artikel yang diposting.</td></tr>';
	}?>
	</tbody>
</table>
<br/><br/>
<?php if(count($articles) > 0){ ?>
<div id="pagination"></div>
<?php } ?>
</article>

<!--<article class="sidebar_right">
	<a href="#"><button class="pager active">1</button></a>
	<a href="#"><button class="pager">2</button></a>
	<a href="#"><button class="pager">3</button></a>
</article>-->

<div class="cleaner"></div>
</div>
<div class="cleaner"></div>
<?php $this->load->view('footer', $right_sidebar); ?>
<script type="text/javascript">
    $(document).ready(function () {
        $('#pagination').smartpaginator({ totalrecords: <?php echo count($articles); ?>, recordsperpage: 20, length: 5, datacontainer: 'article-body', dataelement: 'tr', initval: 0, next: 'Next', prev: 'Prev', first: 'First', last: 'Last'});
    });
</script>